package com.ht.medicaltreatment.viewmodel

import com.hjq.http.EasyHttp
import com.hjq.http.listener.OnHttpListener
import com.ht.medicaltreatment.bean.HaoCaiProgressBean
import com.ht.medicaltreatment.http.api.HaoCaiProgressAPI

class HaoCaiProgressViewModel : BaseViewModel(){
    fun getProgress(id:String,onResult:(HaoCaiProgressBean)->Unit){
        EasyHttp.post(this)
            .api(HaoCaiProgressAPI(id))
            .request(object : OnHttpListener<HaoCaiProgressBean>{
                override fun onHttpSuccess(result: HaoCaiProgressBean) {
                    if(result.code == 200){
                        onResult(result)
                    }else{
                      dismissProgress(result.message)
                    }
                }

                override fun onHttpFail(e: Exception) {
                    dismissProgress(e.message!!)
                }
            })
    }
}
